package com.xuecheng.media.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuecheng.media.model.po.MediaProcess;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author itcast
 * @since 2023-03-27
 */
@Mapper
public interface MediaProcessMapper extends BaseMapper<MediaProcess> {

    //select * from media_process t where t.id % 2 = 0 and ( t.`status` = 1 or t.`status` = 3) and t.fail_count < 3  LIMIT 2;

    /**
     *  根据分片参数获取待处理任务
     * @param shardTotal 分片总数
     * @param shardIndex 分片序号
     * @param count 任务数
     * @return
     */

    List<MediaProcess> getMediaProcessList(@Param("shardTotal") int shardTotal , @Param("shardIndex") int shardIndex , @Param("count") int count);

    /**
     *  开启一个任务
     * @param id  任务id
     * @return
     */
    int startTask(@Param("id") long id);





}
